﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using ESOL.Common.Entity;
using ESOL.Business.Mst;

namespace ESOL.WinUI.Inv
{
    public partial class frmMaintainLocationAdd : BaseForm.frmBaseForm
    {
        #region Variable
        public string SInvCode { get; set; }
        public MstLocationEntity selectedLocation { get; set; }
        #endregion

        #region Constructor
        public frmMaintainLocationAdd()
        {
            InitializeComponent();
        }
        #endregion

        #region Functions

        private bool CheckDate()
        {

            if (txtLocationCodeTitle.Text.Equals(""))
            {
                MessageBox.Show("‘库位编码开头字母’ 不能为空");
                return false;
            }
            if (txtLocationCodeQty.Text.Equals(""))
            {
                MessageBox.Show("‘新增数量’ 不能为空");
                return false;
            }
            return true;
        }

        private bool SaveDate(string sInvCode, string sCodeTitle, int qty)
        {
            if (!CheckDate())
            {
                return false;
            }
            bool result = MstLocationBs.InsertByBatch(sInvCode, sCodeTitle, qty);
            if (result)
            {
                MessageBox.Show("新增成功！");
                return true;
            }
            else
            {
                MessageBox.Show("新增失败！");
                return false;
            }
        }
        #endregion

        #region Events
        private void frmWareHouseLocationAdd_Load(object sender, EventArgs e)
        {
            txtInvCode.Text = SInvCode;
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
             if (SaveDate(txtInvCode.Text, txtLocationCodeTitle.Text.ToUpper(), int.Parse(txtLocationCodeQty.Text)))
          {
               this.DialogResult = DialogResult.OK;
          }
        }
        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
        }
        #endregion





    }
}